ref(routes): replace stats nav-v2 redirect with route-level redirects#111703
ref(routes): replace stats nav-v2 redirect with route-level redirects#111703priscilawebdev wants to merge 1 commit intomasterfrom
Conversation
The navigation-sidebar-v2 feature flag is now fully launched, so the OrganizationStatsWrapper component and its useRedirectNavigationV2Routes hook are no longer needed. Replace with declarative redirectTo entries in the route definitions, pointing /stats/* to /settings/stats/*. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| { | ||
| path: '/stats/', | ||
| withOrgPath: true, |
There was a problem hiding this comment.
Bug: When a route uses both withOrgPath: true and redirectTo, the withOrgPath property is ignored, preventing the creation of organization-prefixed redirect routes and causing 404 errors.
Severity: HIGH
Suggested Fix
Refactor the translateSentryRoute() function to ensure the withOrgPath logic is applied even when redirectTo is present. This likely involves processing withOrgPath to generate both base and organization-prefixed routes before handling the redirectTo property for each generated route.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: static/app/router/routes.tsx#L813-L815
Potential issue: In the `translateSentryRoute()` function, the logic returns early if a
`redirectTo` property is defined on a route. This early return occurs before the logic
that processes `withOrgPath: true` is reached. Consequently, for the new stats redirect
routes, only the non-organization paths (e.g., `/stats/`) are created, while the
organization-prefixed paths (e.g., `/organizations/:orgId/stats/`) are not. Users
navigating to these organization-specific stats paths will encounter a 404 error instead
of being correctly redirected.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed:
withOrgPathsilently ignored onredirectToroutes- Replaced
withOrgPathredirect entries with explicit customer-domain and/organizations/:orgId/...redirect routes so org-prefixed stats URLs are matched and redirected.
- Replaced
- ✅ Fixed: Team redirect targets nonexistent org-prefixed settings path
- Updated the team stats redirect target to
/settings/:orgId/stats/issues/, which is the actual existing settings route.
- Updated the team stats redirect target to
Or push these changes by commenting:
@cursor push 09fbce3f22
Preview (09fbce3f22)
diff --git a/static/app/router/routes.tsx b/static/app/router/routes.tsx
--- a/static/app/router/routes.tsx
+++ b/static/app/router/routes.tsx
@@ -812,22 +812,34 @@
children: [
{
path: '/stats/',
- withOrgPath: true,
+ customerDomainOnlyRoute: true,
redirectTo: '/settings/stats/',
},
{
+ path: '/organizations/:orgId/stats/',
+ redirectTo: '/settings/:orgId/stats/',
+ },
+ {
path: '/stats/issues/',
- withOrgPath: true,
+ customerDomainOnlyRoute: true,
redirectTo: '/settings/stats/issues/',
},
{
+ path: '/organizations/:orgId/stats/issues/',
+ redirectTo: '/settings/:orgId/stats/issues/',
+ },
+ {
path: '/stats/health/',
- withOrgPath: true,
+ customerDomainOnlyRoute: true,
redirectTo: '/settings/stats/health/',
},
{
+ path: '/organizations/:orgId/stats/health/',
+ redirectTo: '/settings/:orgId/stats/health/',
+ },
+ {
path: '/organizations/:orgId/stats/team/',
- redirectTo: '/organizations/:orgId/settings/stats/issues/',
+ redirectTo: '/settings/:orgId/stats/issues/',
},
],
};This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
| { | ||
| path: '/organizations/:orgId/stats/team/', | ||
| redirectTo: '/organizations/:orgId/stats/issues/', | ||
| redirectTo: '/organizations/:orgId/settings/stats/issues/', |
There was a problem hiding this comment.
withOrgPath silently ignored on redirectTo routes
High Severity
The withOrgPath: true on the three new redirect routes is silently ignored. In translateSentryRoute, when redirectTo is set, the function returns early on line 66–68 before reaching the withOrgPath dual-route logic. This means /organizations/:orgId/stats/, /organizations/:orgId/stats/issues/, and /organizations/:orgId/stats/health/ will no longer match any route and will 404 instead of redirecting to their /settings/stats/ equivalents. The old OrganizationStatsWrapper worked because it was a component, not a redirectTo, so withOrgPath was processed.
| { | ||
| path: '/organizations/:orgId/stats/team/', | ||
| redirectTo: '/organizations/:orgId/stats/issues/', | ||
| redirectTo: '/organizations/:orgId/settings/stats/issues/', |
There was a problem hiding this comment.
Team redirect targets nonexistent org-prefixed settings path
High Severity
The /organizations/:orgId/stats/team/ redirect now points to /organizations/:orgId/settings/stats/issues/, but no route exists at /organizations/:orgId/settings/.... The settings routes are defined at /settings/:orgId/... (since settingsRoutes uses path: '/settings/' without withOrgPath). Previously, this redirected to /organizations/:orgId/stats/issues/ which was then caught by the OrganizationStatsWrapper and correctly re-routed to /settings/:orgId/stats/issues/. The new target will hit the catch-all RouteNotFound instead.



The
navigation-sidebar-v2feature flag is now fully launched, so theOrganizationStatsWrappercomponent and itsuseRedirectNavigationV2Routeshook are no longer needed for the stats routes.Replace the component-based redirect with declarative
redirectToentries in the route definitions, pointing/stats/*paths to their/settings/stats/*equivalents. Delete the now-unusedorganizationStatsWrapper.tsxfile.